<script type="text/javascript">
//<![CDATA[        
	$.datepicker.setDefaults({
		dateFormat: 'yy-mm-dd'
	});


	$(function(){
		$(".datepicker").datepicker();
		$(".btn_calendar").click(function(){
			var index = $(".btn_calendar").index($(this));
			$('.datepicker').eq(index).datepicker('show');	
		});	

		$("#frm-search").submit(function(){
			if(!dateRegEx.test($("[name=sch_birth_start]").val())) $("[name=sch_birth_start]").val('');
			if(!dateRegEx.test($("[name=sch_reg_start]").val())) $("[name=sch_reg_start]").val('');
			
			var link = '/member/memberList';
			if($("[name=sch_birth_start]").val()) link += '/sch_birth_start/'+encodeURIComponent($("[name=sch_birth_start]").val());
			if($("[name=sch_birth_end]").val()) link += '/sch_birth_end/'+encodeURIComponent($("[name=sch_birth_end]").val());
			if($("[name=sch_reg_start]").val()) link += '/sch_reg_start/'+encodeURIComponent($("[name=sch_reg_start]").val());
			if($("[name=sch_reg_end]").val()) link += '/sch_reg_end/'+encodeURIComponent($("[name=sch_reg_end]").val());
			if($("[name=sch_gender]").val()) link += '/sch_gender/'+encodeURIComponent($("[name=sch_gender]").val());
			if($("[name=sch_keyname]").val()) link += '/sch_keyname/'+encodeURIComponent($("[name=sch_keyname]").val());
			if($("[name=sch_keyword]").val()) link += '/sch_keyword/'+encodeURIComponent($("[name=sch_keyword]").val());

			location.replace(link);
			return false;
		});
	});
//]]>
</script>
<div class="box_type02">
	<h2 class="txt">회원리스트</h2>
	<p class="icon"><a href="javascript:void(0);" class="icon_m04">매뉴얼</a></p>

	<!--[s] 검색 -->
	<form name="frmSearch" id="frm-search">
		<fieldset class="search_type01 c_box">
			<legend>검색</legend>
			<p>
				<input type="text" id="" name="sch_birth_start" class="ip datepicker" style="width:126px;" value="생일" />
				<a href="javascript:void(0);" class="btn_calendar">달력보기</a>
				<span class="txt_type01">~</span>
				<input type="text" id="" name="sch_birth_end" class="ip datepicker" style="width:126px;" value="" />
				<a href="javascript:void(0);" class="btn_calendar">달력보기</a>
			</p>
	
			<p class="mt5">
				<input type="text" id="" name="sch_reg_start" class="ip datepicker" style="width:126px;" value="가입일" />
				<a href="javascript:void(0);" class="btn_calendar">달력보기</a>
				<span class="txt_type01">~</span>
				<input type="text" id="" name="sch_reg_end" class="ip datepicker" style="width:126px;" value="" />
				<a href="javascript:void(0);" class="btn_calendar">달력보기</a>
			</p>
	
			<p class="mt5">
				<select name="sch_gender" style="width:100px;">
					<option value="">성별</option>
					<option value="M" <?php if($param['sch_gender']=='M'){?>selected<?php }?>>남성</option>
					<option value="F" <?php if($param['sch_gender']=='F'){?>selected<?php }?>>여성</option>
				</select>
				<select name="sch_keyname" style="width:100px;">
					<option value="name">이름</option>
					<option value="user_id">아이디</option>
				</select>
				<input type="text" id="" name="sch_keyword" class="ip" style="width:134px;" value="" />
			</p>
			<input type="submit" class="btn_search_m" style="position:absolute;left:386px;top:15px;" title="검색" value="" />
			<a href="/member/memberForm" class="right"><img src="/theme/<?=$_theme?>/images/common/btn_write.gif" alt="등록" /></a>
		</fieldset>
	</form>
	<!--[e] 검색 -->

	<!--[s] 목록 -->
	<table cellspacing="0" summary="회원리스트" class="lines">
		<caption>회원리스트</caption>
		<thead>
		<tr>
			<th scope="col" width="56">No.</th>
			<th scope="col">아이디</th>
			<th scope="col" width="130">이름</th>
			<th scope="col" width="63">성별</th>
			<th scope="col" width="63">나이</th>
			<th scope="col" width="130">최근접속일</th>
			<th scope="col" width="130">회원가입일</th>
			<th scope="col" width="42">설정</th>
		</tr>
		</thead>
		<tbody>
		<?php 
			foreach($rst as $row){
				$login_date = ($row->login_date) ? mysqldatetime_to_timestamp($row->login_date) : null;
				
				$age = null;
				if($row->birth_date){
					$birth_year = substr($row->birth_date,0,4);
					$age = (date('Y') - $birth_year)+1;	
				}
		?>
		<tr>
			<th scope="row"><p><?php echo $list_no;?></p></th>
			<td><div><?php echo $row->user_id;?></div></td>
			<td class="tal"><div><?php echo $row->name;?></div></td>
			<td><div><?php echo $row->gender;?></div></td>
			<td><div><?php echo $age?></div></td>
			<td><div><?php echo $login_date;?></div></td>
			<td><div><?php echo date('Y-m-d / H:i',mysqldatetime_to_timestamp($row->reg_date));?></div></td>
			<td><div><a href="/member/memberForm/id/<?php echo $row->id;?>/page/<?php echo $page;?>" class="icons icon_m01">설정</a></div></td>
		</tr>
		<?php 
				$list_no--;
			}
		?>
		</tbody>
	</table>
	<!--[e] 목록 -->

	<!--[s] 페이징 -->
	<div class="paging_all c_box">
		<div class="paging">
			<?php echo $paging?>
		</div>
	</div>
	<!--[e] 페이징 -->

	<!--[s] Tip -->
	<dl id="tip" class="mt30">
		<dt>Tip</dt>
		<dd>인터넷익스플로러의 '호환성보기' 기능을 사용중인 접속자에게 자동으로 최신버전 기준으로 사이트를 출력하도록 처리합니다.</dd>
		<dd>코딩방식에 따라 특정 버전의 브라우저에서 사이트가 깨질수 있으니, 충분한 테스트 후 기능을 설정해 주시기 바랍니다.</dd>
	</dl>
	<!--[e] Tip -->
</div>